-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added kpi component to models #4
Conversation
Pertains to #3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @AntonioLCM! The help is much appreciated.
I have some suggestions to improve the functionality and example, but the setup is good!
pydfy/template/src/partials/kpi.html
Outdated
<div class="text-xs mb-2">{{ "Goal: {:,} ({:+.2f} %)".format(component.goal, | ||
(component.current - | ||
component.goal) / | ||
component.goal * 100) }}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The layout looks good! While experimenting I did stumble upon a zero-division error when the target equals 0. Since this becomes tedious to code in these html templates, my suggestion would be to move this logic to a @property
on the KPI
called _percent
for instance. Also see the _base64_data
field on the Image
component. Then you can access e.g. the _percent
column and return "Infinity" when the target equals 0, which is how PowerBI handles it.
(Another feature you could consider adding for this use case is: a flag called use_value
with default False
. If True
, we display the absolute difference instead of relative. This does require changing the template to handle this as well though.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I appreciate your time and suggestions. Maybe the suggested feature here could be a new issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I'll add a new issue for the suggestion.
As a last request: could you render and commit the new |
…different component and keep in line with 'blue'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @AntonioLCM! Leaving a star would be much appreciated if you like the project. Keep an eye on the issue list if you want to stay involved 😉
Included an example in examples/iris/.
Question: Is the formatting of the output in line with what you expected? If not, please do feel free to let me know what it should look like.